package prefuse.tp.svn;

import java.util.logging.Logger;

import prefuse.action.assignment.ColorAction;
import prefuse.data.Node;
import prefuse.util.ColorLib;
import prefuse.visual.VisualItem;

/**
 * Set node text colors
 */
public class GraphRadial_textColorAction extends ColorAction {
        public GraphRadial_textColorAction(String group) {
            super(group, VisualItem.TEXTCOLOR, ColorLib.gray(0));
            add("_hover", ColorLib.rgb(0,0,0));
            add("ingroup('_search_')", ColorLib.rgb(255,10,10));
            add("ingroup('_focus_')", ColorLib.rgb(0,0,0));
        }
        @Override
        public int getColor(VisualItem item) {
        	
        	Node n = (Node) item.getSourceTuple();
            if(n.getInt("type") == GraphRadial_Affectations.UE)
            	// si moin de 6 étudiant dans l'UE, texte en rouge
            	if(n.getOutDegree()< 6)
            		return ColorLib.rgb(255, 0, 0);
        	
        	
            Object o = lookup(item);
            if ( o != null ) {
                if ( o instanceof ColorAction ) {
                    return ((ColorAction)o).getColor(item);
                } else if ( o instanceof Integer ) {
                    return ((Integer)o).intValue();
                } else {
                    Logger.getLogger(this.getClass().getName())
                        .warning("Unrecognized Object from predicate chain.");
                }
            }
            return m_defaultColor;   
        }
    }